<template>
  <div class="app-container system-user">
    <!-- 搜索表单区域 -->
    <el-form
      :inline="true"
      :model="searchForm"
      class="form-search"
      size="small"
    >
      <el-form-item label="名称">
        <el-input v-model="searchForm.userName" placeholder="名称"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="mini" icon="el-icon-search">
          查询
        </el-button>
        <el-button icon="el-icon-refresh" size="mini">
          重置
        </el-button>
      </el-form-item>
    </el-form>
    <!-- 按钮区域 -->
    <div class="btn-box">
      <el-button size="mini" type="primary" icon="el-icon-plus">
        新增
      </el-button>
      <div>
        <el-tooltip class="item" effect="dark" content="刷新" placement="top">
          <el-button
            size="mini"
            circle
            icon="el-icon-refresh"
            :disabled="loading"
          ></el-button>
        </el-tooltip>
      </div>
    </div>
    <!-- 表格区域 -->
    <el-table
      stripe
      :data="tableData"
      style="width: 100%"
      :header-cell-style="{ background: '#F8F8F9', color: '#606266' }"
    >
      <el-table-column label="#" type="index"> </el-table-column>
      <el-table-column prop="order" label="排序"> </el-table-column>
      <el-table-column prop="number" label="编号"> </el-table-column>
      <el-table-column prop="name" label="名称"> </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" icon="el-icon-edit">
            二维码
          </el-button>
          <el-button type="text" size="small" icon="el-icon-edit">
            修改
          </el-button>
          <el-button type="text" size="small" icon="el-icon-delete">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页区域 -->
    <div class="pagination-warp">
      <el-pagination
        :current-page="current"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </el-pagination>
    </div>
    <!-- 编辑、删除对话框 -->
  </div>
</template>

<script>
export default {
  name: 'UserAdmin',
  data() {
    return {
      loading: true, // 加载遮罩
      dialogEditVisible: false, // 编辑对话框显示与隐藏
      dialogAddVisible: false, // 新增对话框显示与隐藏
      tableData: [
        {
          order: 1,
          name: '1号展厅',
          number: '011'
        },
        {
          order: 2,
          name: '1号展柜',
          number: '3'
        }
      ], // 表格数据
      current: 1, // 当前页
      limit: 10, // 一页几个
      total: 0, // 总数
      searchForm: {
        // 搜索表单
        roleId: null,
        userName: '',
        userPhone: ''
      }
    };
  },
  created() {},
  methods: {
    /**
     * 处理分页修改
     */
    handleSizeChange(val) {
      this.limit = val;
      this.getAllUser();
    },
    handleCurrentChange(val) {
      this.current = val;
      this.getAllUser();
    },
    /**
     * 重置查询
     */
    resetSearch() {
      this.searchForm = {
        roleId: null,
        userName: '',
        userPhone: ''
      };
      this.getAllUser();
    }
  }
};
</script>

<style lang="scss">
.form-search {
  .el-input {
    width: 240px;
  }
}
</style>

<style lang="scss" scoped>
.system-user {
  .pagination-warp {
    margin-top: 20px;
    position: relative;
    .el-pagination {
      position: absolute;
      right: 0;
      top: 0;
    }
  }

  .el-table {
    margin-top: 10px;
  }

  .btn-box {
    display: flex;
    justify-content: space-between;
  }

  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }
}
</style>
